extend personLeft.pug

block append pageStyle
	link(href='${relativePath}/static/css/personCenter/myAttention.css' type="text/css" rel="stylesheet")
	link(href="${relativePath}/static/css/shopping/foundation.min.css" rel="stylesheet" type="text/css")
	link(href="${relativePath}/static/css/shopping/foundation-datepicker.css" rel="stylesheet" type="text/css")

block personRight
	div.rightContent.fl
		div.myAttentionBox
			ul.myList
				//- li.fl
				//- 	div.topImg
				//- 		img(src="${relativePath}/static/imgs/latest01.png")
				//- 	a(href="javascript:;").companyName 志玲广告有限公司
				//- 	p.aboutName 普通安装
				//- 	a(href="javascript:;").chat 聊天
				//- 	div.gzBox 已关注
				

	script#attentionList(type="text/html")
		| {{set arr = data.userList}}
		| {{each arr temp}}
		li.fl(id="{{temp.member_id}}")
			div.topImg
				img(src="{{temp.avatar_img}}")
			| <a href="javascript:;" class="companyName" if(temp.username == null && temp.verify_status == 2) style="background-image:url(${relativePath}/static/imgs/bs.png)"> {{if !temp.username}}无 {{else}}{{temp.username}}{{/if}}</a>
			p.aboutName {{temp.type}}
			a(href="javascript:;").chat 聊天
			div.gzBox 已关注
		| {{/each}}



	//- 分页
	div.pageBox
		nav.pageNav
			
			div.paginationOne.page


block append pageScript

	script.
		$(function(){
			$("#myAttention").addClass("current").siblings().removeClass("current");
			//- 取消关注
			$(".myList").on("click",".gzBox",function(){
				var $this = $(this).closest("li");
				$.getJSON(shopIp+"/Concern/concern?callback=?",{
					userToken:token,
					os:"web",
					concern_id:$this.attr("id")
				},function(data){
					//console.log(data);
					if(data.status == 200) {
						layer.msg(data.msg);
						$this.remove();
					}
				})
			})
			//- 关注列表分页
			function attentionList(pageNum){
				$.getJSON(shopIp+"/Concern/listConcern?callback=?",{
					userToken:token,
					os:"web",
					size:5,
					page:pageNum
				},function(data){
					//console.log(data);
					var data1 = data.data;
					var myAttention = template("attentionList",data);
					console.log(data1);
					if(data1.length <1) {
						$(".myList").append("<img class='imgBig' src='${relativePath}/static/imgs/zw.png'/>");
						$(".myList").css("text-align","center");
					}else{
						$(".myList").append(myAttention);
						$(".page").html("").pagination({
							pageCount : data.data.pageCount,
							current : pageNum,
							keepShowPN : true,
							count : 2,
							homePage : "1",
							endPage : data.data.pageCount,
							coping : true,
							prevContent : "< 上一页",
							nextContent : "下一页 >",
							callback : function(page) {
								attentionList(page.getCurrent());
							}
						});
					}
					//console.log(myAttention);
				})
			}

			attentionList(1);
		})


